-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
USB sync to drive: enhanced services_start / services_stop scripts to… #2
Conversation
Thanks for another PR. While you did this I also thought about how to solve this the most elegant way and came up with following ideas:
I'm leaning towards the first and last option. Last option to prevent it running multiple times and event listeners to unmount before quitting. Could you change the |
Love it - this is of course more clean. And I agree the combination of 1+3 sounds preferred. JavaScript is single-threaded afaik. So assume the kill signal processing passes to the handler and hence is entered into the event queue, rsync will always finish first. But I am not sure about the exact behavior for handling system signals in node.js and scripts. Another approach could be to use a semaphore around rsync execution, which can be evaluated by the signal handler. Let me know how I can help and of course feel free to adjust the stop script the way you need it. |
Sadly no, I've built the script to detach the rsync shells from itself to not wait until it finishes before starting the next rsync (when there are more targets to rsync to). Maybe we could convert this part to Promises? I've done the cleanup part, sadly I couldn't figure out the wait part to wait (e.g. 30 seconds) before killing still running rsync processes. Do you know how I can push to your branch, so we can fix everything in this PR before I merge it. |
Hey - I've been offline for a while, sorry for that. Is there commits I can pull into my branch, so it becomes part of the PR ? Or can you accept my PR into yours and we continue to build from there ? Admit I am not the git expert... If all that does not work I could give you access to my repo. I'd try use 'setTimeout()' for a 30sec wait - but I have not looked into the code yet. On the other side, if the rsync runs every say 30 seconds to 1 minute , there is little to sync every single time. So I would assume that in a real photobox use-case, until one eventually shuts down the rsync script via config change, the box is not active (active as being currently used in an event) and the likelyhood of missing pictures copied on the USB stick during rsync is low. So thinking about that, I believe if we chose to hard stop any possibly active rsync and then cleanly unmount the USB device should bear low risk to miss files. And if then worst case one is missed from syncing to the stick, anyways the files are still on the box. Just looking at risk vs. effort. Suggest we get all devs merged first and go from there ? Hmm - and maybe we integrate some sort of status information about the rsync - i.e. count number of files on both sides or do some sort of |
Hey and thanks to both of you for your work! Once you're done @thatonedude3470, you can force push over your current |
Forgot to mention @thatonedude3470 , you need to accept the invite to push to mentioned repo. |
I continue the work in https://github.com/andi34/photobooth-wip - see code changes there.
Todo:
Note:
Commit: 4eaab02 |
Sorry for my long inactivity, couldn't work on the go and forgot to notify you. Thanks for all the help, I'll look into the changes and merge them after some testing :) |
@jacques42 what IDE or editor are you using? Okay so there is a lot to be done, just for reference I pushed the changes I couldn't commit into your git into the anotherfix branch. |
Plain good old emacs on SSH / TTY :-) |
Hey - I took a look at the code in your branch, and understand why it does not merge. I think currently we have different ideas on how to approach this, which of course is fine but I do not want to get in your way here. This is your idea and script, hence you lead. That said, I will step back a bit and not continue develop my branch further - it does not make sense with both of us working the same thing in parallel but with different approaches. Again - I do like the idea a lot and I am happy to help integrate to photobooth where I can. Yet I believe at this point it is a better approach if you lead the development on the sync script itself, and I support with intergrations to PB where I can. Let me know if you view this differently but I think this is where we are right now. |
Hey @thatonedude3470 - I wanted to check back with you, this work has been sitting stale for a while. I think that during the holiday break I'd find some time to finish the work. I like the feature and it should go to the master, it would be sad to see it sitting stale forever. Let me know what you think and whether you want to work on it at all. Or once I find time I'll give it a shot and try to finalize it into a functioning version for to include to the next release. |
... be more robust.
Thanks for checking. How could I miss that - I think I actually never tested the core use-case of taking a picture omg. I did some additions to not only check for the PID file as such but have the script be a bit more robust - both before starting service but also when stopping services.
And one small tweak in sync-to-drive.js ---- when writing the PID to file, I believe it was meant to be 'flags' instead of 'mode'. And I would prefer mode of 'w' to overwrite an existing, possibly stale log file. 'wx' would force the process to exit when the file exists. but eventually not the actual process itself.
andi34#115